<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  // 非空字符，为true
  console.log( Boolean( "" ) );
  console.log( Boolean( "hello" ) );
  console.log( Boolean( " " ) );
  console.log( Boolean( "false" ) );
  console.log( Boolean( "0" ) );
  console.log( Boolean( "undefined" ) );

  console.log("-----");

  // 非0为true，NaN和0为false
  console.log( Boolean( 0 ) );
  console.log( Boolean( 1 ) );
  console.log( Boolean( -1 ) );
  console.log( Boolean( 1.345 ) );
  console.log( Boolean( -1.345 ) );
  console.log( Boolean( NaN ) );
  
  console.log("======");

  // undefined和null为false
  console.log( Boolean( undefined ) );
  console.log( Boolean( null ) );

  // 对象，数组，函数都为true
  console.log( Boolean( {} ) )
  console.log( Boolean( {flag: false} ) )
  console.log( Boolean( [] ) )
  console.log( Boolean( [false] ) )
  console.log( Boolean( [0] ) )
  console.log( Boolean( [""] ) )
  console.log( Boolean( [undefined] ) )
  console.log( Boolean( [null] ) )
  console.log( Boolean( function(){} ) )
  
</script>
</html>